home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 1999 January - Disc 2
/
Macworld (1999-01) (Disk 2).dmg
/
Serious Demos
/
Symbolic Composer 4.2
/
Environment
/
Projects
/
Stretching the Mind
/
symbol-to-mapped-integer examp.
< prev
next >
Wrap
Lisp/Scheme
|
1996-11-15
|
3KB
|
82 lines
(setq harmonized-melodies
(filter-harmonize2 melody-1-source melody-2-source 12
(activate-tonality (harmonic-minor b 2 ))
'((4 4))
'((1 2 6 8 10 11))))
Since filter-harmonize is called with giving tonality in form
(activate-tonality (harmonic-minor b 2))
select it and notice it returns ((b 2 c# 3 d 3 e 3 f# 3 g 3 a# 3))
Now, within filter-harmonize2 it is supplied to build-maptable
(defun filter-harmonize2 (mel1 mel2 mod-val tonality n-control s-values)
(diagnostic2 "filter-harmonize" $cr$)
(setq mel1 (symbol-trim (length mel2) mel1))
(prog (out1 out2 gap swap counter n n-times n-count n-values s-master semitones
maptable)
(setq maptable (build-maptable (car tonality)))
This means that maptable is build this way
(setq maptable (build-maptable (car (activate-tonality (harmonic-minor b 2)))))
Now you can map symbols.
(symbol-to-mapped-integer 'a maptable)
--> 35
(symbol-to-mapped-integer 'b maptable)
--> 37
Notice that the tonality was harmonic-minor and that's why the mapping
is 37. That means: 2 semitones. The map results are ABSOLUTE MIDI note
values.
Now make a checking that the result is within given absolute boundaries
and if exceed transpose the symbol down until it does not exceed. Then
collect the symbol on list which you return.
(defun process-mapping (symbols tonality)
(let ((collect nil)
(maptable (build-maptable (car tonality))))
(dolist (x symbols)
(push (symbol-to-mapped-integer x maptable) collect)) ;; <<- put here your test & integer to symbol
(nreverse collect)))
(process-mapping '(a b c d) (activate-tonality (major c 4)))
--> (35 37 38 40)
Here is the principle
(defun symbol-remap (symbols tonality)
(let ((collect nil)
(maptable (build-maptable (car tonality))))
(dolist (x symbols)
(let ((note (- (symbol-to-mapped-integer x maptable) 48)))
(if (> note 20)
(push (integer-to-symbol (- note 12)) collect)
(push (integer-to-symbol note) collect))))
(nreverse collect)))
(symbol-remap '(a b c d e f g h i j k l m n o p q r s t u v) (activate-tonality (major c 4)))
--> (a c e f h j l m o q r t j l m o q r t v x y)
Or you might use the mod. Here the note is moded which keeps the value
within 0 to 11 whatever is the note. If you use (mod note 24) then the area
is 24 semitones. Area does not have to be an octave, it might be as well
5 semitones. So, whatever happens in the symbol it is coerced to happen
within that window.
(defun symbol-remap (symbols tonality)
(let ((collect nil)
(maptable (build-maptable (car tonality))))
(dolist (x symbols)
(let ((note (- (symbol-to-mapped-integer x maptable) 48)))
(push (integer-to-symbol (mod note 12)) collect)))
(nreverse collect)))
(symbol-remap '(a b c d e f g h i j k l m n o p q r s t u v) (activate-tonality (major c 4)))
--> (a c e f h j l a c e f h j l a c e f h j l a)